package com.huatai.exchange.impl;

import com.faneui.common.exception.BusinessException;
import com.huatai.exchange.dal.dao.ExcAutoSendCustMailTaskDAO;
import com.huatai.exchange.dal.model.ExcAutoSendCustMailTask;
import com.huatai.exchange.service.ExcAutoSendCustMailTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ExcAutoSendCustMailTaskServiceImpl implements ExcAutoSendCustMailTaskService {

    @Autowired
    private ExcAutoSendCustMailTaskDAO excAutoSendCustMailTaskDAO;

    @Override
    public List<ExcAutoSendCustMailTask> queryExcAutoSendCustMailTaskList(ExcAutoSendCustMailTask excAutoSendCustMailTask) throws BusinessException {
        List<ExcAutoSendCustMailTask> tasks = null;
        try {
            tasks = excAutoSendCustMailTaskDAO.queryByModel(excAutoSendCustMailTask);
        } catch (Exception ex) {
            BusinessException.throwBusinessException(ex);
        }
        return tasks;
    }

    @Override
    public ExcAutoSendCustMailTask queryExcAutoSendCustMailTask(String id) throws BusinessException {
        ExcAutoSendCustMailTask task = null;
        try {
            task = excAutoSendCustMailTaskDAO.queryById(id);
        } catch (Exception ex) {
            BusinessException.throwBusinessException(ex);
        }
        return task;
    }

    @Override
    public void modifyExcAutoSendCustMailTask(ExcAutoSendCustMailTask excAutoSendCustMailTask) throws BusinessException {
        try {
            excAutoSendCustMailTaskDAO.updateById(excAutoSendCustMailTask);
        } catch (Exception ex) {
            BusinessException.throwBusinessException(ex);
        }
    }

    @Override
    public Long modifyNextDate(String id, String oldNextDate, String newOldDate) throws BusinessException {
        Long num = null;
        try {
            num = excAutoSendCustMailTaskDAO.updateNextDate(id, oldNextDate, newOldDate);
        } catch (Exception ex) {
            BusinessException.throwBusinessException(ex);
        }
        return num;
    }
}
